﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title id='Description'>This example shows the set the cells and columns alignment.
    </title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.classic.css" type="text/css" />
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.darkblue.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxradiobutton.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
    <script type="text/javascript" src="../../scripts/gettheme.js"></script>
    <script type="text/javascript" src="generatedata.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var theme = '';

            // prepare the data
            var data = generatedata(200);

            var source =
            {
                localdata: data,
                datatype: "array"
            };

            var columns = [
                  { text: 'Id', datafield: 'id', width: 50, cellsalign: 'center', align: 'center' },
                  { text: 'First Name', datafield: 'firstname', width: 100, cellsalign: 'center', align: 'center' },
                  { text: 'Last Name', datafield: 'lastname', width: 100, cellsalign: 'center', align: 'center' },
                  { text: 'Product', datafield: 'productname', width: 180, cellsalign: 'center', align: 'center' },
                  { text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'center', align: 'center' },
                  { text: 'Unit Price', datafield: 'price', width: 90, cellsalign: 'center', align: 'center', cellsformat: 'c2' },
                  { text: 'Total', datafield: 'total', width: 100, cellsalign: 'center', align: 'center', cellsformat: 'c2' }
                ];

            // initialize jqxGrid
            $("#jqxgrid").jqxGrid(
            {
                width: 670,
                source: source,
                theme: theme,
                selectionmode: 'multiplecellsextended',
                columns: columns
            });

            $("#leftbutton").jqxRadioButton({ theme: theme, width: 55 });
            $("#centerbutton").jqxRadioButton({ checked: true, theme: theme, width: 70 });
            $("#rightbutton").jqxRadioButton({ theme: theme, width: 70 });

            var setAlignment = function (align) {
                $("#jqxgrid").jqxGrid('beginupdate');
                for (var index = 0; index < columns.length; index++) {
                    $("#jqxgrid").jqxGrid('setcolumnproperty', columns[index].datafield, 'align', align);
                    $("#jqxgrid").jqxGrid('setcolumnproperty', columns[index].datafield, 'cellsalign', align);
                }
                $("#jqxgrid").jqxGrid('endupdate');
            }

            $("#leftbutton").bind('checked', function () {
                setAlignment('left');
            });
            $("#centerbutton").bind('checked', function () {
                setAlignment('center');
            });
            $("#rightbutton").bind('checked', function () {
                setAlignment('right');
            });

        });
    </script>
</head>
<body class='default'>
    <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
        <div id="jqxgrid">
        </div>
        <div>
            <h3>Alignment</h3>
            <div style="float: left;" id="leftbutton">Left</div>
            <div style="float: left;" id="centerbutton">Center</div>
            <div style="float: left;" id="rightbutton">Right</div>
        </div>
    </div>
</body>
</html>
